package at.fhv.framework.filter;

import at.fhv.framework.interfaces.Pull;

/**
 * @author Michael
 * @version 1.0
 * @created 16-Nov-2011 10:05:24
 */
public abstract class PassivePullFilter<IN, OUT> extends Filter<IN, OUT>
		implements Pull<OUT> {

	protected Pull<IN> _source;

	public PassivePullFilter(Pull<IN> source) {
		_source = source;
	}

	/**
	 * IN data = _source.read(); execute(data);
	 */
	@Override
	public OUT read() {
		OUT entity = createEntity();
		boolean isFull;
		do {
			isFull = execute(entity, _source.read());
		} while (!isFull);

		return entity;
	}

}